﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using IMPlant.Core.Data.Ado;
using SMTC.Model.TestCore;
using System.Data.Common;
using IMPlant.Core.Data.Unity;
using IMPlant.Core.Data.Ado.BaseSupport;
using SMTC.BO.AnalyzePara;
using SMTC.WebCommon.Common;
using SMTC.Model.Model;


public partial class Test_TestMaster : BasePage
{
    private AnalyzeParaQueryServices _QueryServices = new AnalyzeParaQueryServices();
    private AnalyzeParaProccessServices _ProccessServices = new AnalyzeParaProccessServices();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //如数据库中para内容为空时
            SMT_paraModel model = _QueryServices.getPara();
            if (model != null)
            {
                if (model.YellowAlert != null)
                {
                    txt_YellowAlert.Text = model.YellowAlert.ToString();
                }
                else
                {
                    txt_YellowAlert.Text = "0";
                }

                if (model.YellowAlert != null)
                {
                    txt_RedAlert.Text = model.RedAlert.ToString();
                }
                else
                {
                    txt_RedAlert.Text = "0";
                }

                if (model.TargetTime != null)
                {
                    TextBoxTaragetTime.Text = model.TargetTime.ToString();
                }
                else
                {
                    txt_RedAlert.Text = "0";
                }

            }
            else
            {
                txt_YellowAlert.Text = "0";
                txt_RedAlert.Text = "0";
                txt_RedAlert.Text = "0";
            }
        }

    }
    protected void ButtonServe_Click(object sender, EventArgs e)
    {
        if (_ProccessServices.UpdatePara(this.GetModelFormPage()) == true)
        {
            ShowMessage(Resources.Resource.ParaSaveSuccess);//"参数保存成功！"
        }
        else
        {
            ShowMessage(Resources.Resource.ParaSaveFailed);//"参数保存失败！"
        }
    }

    public SMT_paraModel GetModelFormPage()
    {
        SMT_paraModel model = new SMT_paraModel();
        model.TargetTime = ConvertDateType.FloatTryFormat(TextBoxTaragetTime.Text.Trim());
        model.YellowAlert = ConvertDateType.IntParse(txt_YellowAlert.Text.Trim());
        model.RedAlert = ConvertDateType.IntParse(txt_RedAlert.Text.Trim());
        return model;
    }
}